package com.rybbaby.tss.front.tssMemberCheckAttendanceHistory.service.imp;

import com.rybbaby.tss.core.web.service.imp.BaseServiceImp;
import com.rybbaby.tss.front.tssMemberCheckAttendance.entity.TssMemberCheckAttendance;
import com.rybbaby.tss.front.tssMemberCheckAttendanceHistory.dao.ITssMemberCheckAttendanceHistoryDao;
import com.rybbaby.tss.front.tssMemberCheckAttendanceHistory.entity.TssMemberCheckAttendanceHistory;
import com.rybbaby.tss.front.tssMemberCheckAttendanceHistory.service.ITssMemberCheckAttendanceHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @description 会员考勤记录表数据库操作服务实现
 * 
 * @author 雷春琼
 *
 * @createDate 2017-08-10 上午10:33:46
 */
@Service
@Transactional
public class TssMemberCheckAttendanceHistoryServiceImp extends BaseServiceImp<TssMemberCheckAttendanceHistory> implements ITssMemberCheckAttendanceHistoryService {

    @Autowired
    private ITssMemberCheckAttendanceHistoryDao tssMemberCheckAttendanceHistoryDao;

    @Override
    public boolean batchSave(List<TssMemberCheckAttendance> entitys) throws Exception {

        ArrayList<TssMemberCheckAttendanceHistory> tssMemberCheckAttendanceHistories = new ArrayList<TssMemberCheckAttendanceHistory>();
        String id = "";
        for (int j = 0; j < entitys.size(); j++) {
            TssMemberCheckAttendanceHistory tssMemberCheckAttendanceHistory = new TssMemberCheckAttendanceHistory();
            id = UUID.randomUUID().toString().replace("-", "");
            System.out.println(id);
            tssMemberCheckAttendanceHistory.setId(id);
            tssMemberCheckAttendanceHistory.setCheckAttendanceId(entitys.get(j).getId());
            tssMemberCheckAttendanceHistory.setMemberId(entitys.get(j).getMemberId());
            tssMemberCheckAttendanceHistory.setClassId(entitys.get(j).getClassId());
            tssMemberCheckAttendanceHistory.setType(entitys.get(j).getType());
            tssMemberCheckAttendanceHistory.setAttendenceStatus(entitys.get(j).getAttendenceStatus());
            tssMemberCheckAttendanceHistory.setRemark(entitys.get(j).getRemark());
            tssMemberCheckAttendanceHistory.setAdminUserId(entitys.get(j).getAdminUserId());
            tssMemberCheckAttendanceHistory.setCreateTime(entitys.get(j).getCreateTime());
            tssMemberCheckAttendanceHistory.setUpdateTime(entitys.get(j).getUpdateTime());
            tssMemberCheckAttendanceHistory.setVersion(entitys.get(j).getVersion());
            tssMemberCheckAttendanceHistories.add(j,tssMemberCheckAttendanceHistory);
        }
        /*for (TssMemberCheckAttendance entity : entitys) {
            id = UUID.randomUUID().toString().replace("-", "");
            System.out.println(id);
            tssMemberCheckAttendanceHistory.setId(id);
            tssMemberCheckAttendanceHistory.setCheckAttendanceId(entity.getId());
            tssMemberCheckAttendanceHistory.setMemberId(entity.getMemberId());
            tssMemberCheckAttendanceHistory.setClassId(entity.getClassId());
            tssMemberCheckAttendanceHistory.setType(entity.getType());
            tssMemberCheckAttendanceHistory.setAttendenceStatus(entity.getAttendenceStatus());
            tssMemberCheckAttendanceHistory.setRemark(entity.getRemark());
            tssMemberCheckAttendanceHistory.setAdminUserId(entity.getAdminUserId());
            tssMemberCheckAttendanceHistory.setCreateTime(entity.getCreateTime());
            tssMemberCheckAttendanceHistory.setUpdateTime(entity.getUpdateTime());
            tssMemberCheckAttendanceHistory.setVersion(entity.getVersion());
            tssMemberCheckAttendanceHistories.add(tssMemberCheckAttendanceHistory);
        }*/
        return tssMemberCheckAttendanceHistoryDao.batchSave(tssMemberCheckAttendanceHistories);
    }
}
